<template>
    <div>
        <div class="jc">
            <span>
                <h2>热点添加</h2>
            </span>
        </div>

        <div style="margin:5px">
            <table style="font-size:18px;width:40%">
                <tr>
                    <td>描述</td>
                    <td><input type="text" v-model="hot.memo"></td>
                </tr>
                <tr>
                    <td>热度</td>
                    <td><input type="text" v-model="hot.hot"></td>
                </tr>
                <tr>
                    <td>类型</td>
                    <td><input type="text" v-model="hot.type"></td>
                </tr>
                <tr>
                    <td>
                        <img style="width:100px;height:100px" 
                            :src="`${imgUrl}/api/adm/book/show/`+hot.picture" >
                    </td>
                    <td>
                        <input type="file" ref="pic">
                    </td>
                </tr>
            </table>
            <hr>
            <div style=" display:flex;justify-content:space-between;">
            <button @click="back()" style="margin:5px">返回列表</button>
            <button @click="submit()" style="margin:5px 100px">提交</button>
        </div>
        </div>
    </div>
</template>
<script>
    export default {
        name:'',
        props:[],
        data() {
            return {
                hot:{memo:'',hot:1,type:"",picture:''},
            }
        },
        methods:{
            //返回列表
            back(){
                this.$router.push({path:"/adm/hot/hot"})
            },
            submit(){
                let fd = new FormData();
                fd.append("memo",this.hot.memo)
                fd.append("hot",this.hot.hot)
                fd.append("type",this.hot.type)
                let fs = this.$refs.pic.files;
                if(fs.length>0 && fs[0] != null){
                    fd.append("pic",fs[0])
                }
                
                var  _this = this;
                this.$postFile("/api/adm/hot/addHot",fd).then(
                    function(resp){
                        _this.hot.picture = resp.data.data.picture
                    }
                )
            }
        },
        mounted(){

        }
    }
</script>
<style scoped="scoped">
    .jc{
        margin: 0 5px;
        border-bottom: 2px solid gray;
    }
    table tr{
        line-height: 50px
    }
</style>
